aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/[username]/invoice
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-04-04 15:11:42 -0700
committerAdam Soltys <[email protected]>2023-04-04 15:11:42 -0700
commitbf83d563fdac23da32b547130f0e24b48bf4b743 (patch)
tree5012961ce3e010e551749802b070b52fe7f9f8a9 /src/routes/(app)/[username]/invoice
parent048766bccca842523192ba183fbbfebf879746fd (diff)
downloadcoinos-ui-bf83d563fdac23da32b547130f0e24b48bf4b743.tar.gz
coinos-ui-bf83d563fdac23da32b547130f0e24b48bf4b743.zip
rate refactoring
Diffstat (limited to 'src/routes/(app)/[username]/invoice')
-rw-r--r--src/routes/(app)/[username]/invoice/[hash]/+layout.server.js6
-rw-r--r--src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte8
2 files changed, 8 insertions, 6 deletions
diff --git a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js b/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js
index 7cf87e14..04d413bb 100644
--- a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js
+++ b/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js
@@ -12,10 +12,12 @@ export async function load({ depends, params, url, parent }) {
if (user && invoice.uid !== user.id && !url.pathname.includes('tip'))
throw redirect(307, `/send/invoice/${hash}`);
- let { amount, received } = invoice;
+ let { amount, pending, received } = invoice;
amount = parseInt(amount);
- let paid = (!amount && received) || (amount > 0 && received >= amount);
+ console.log("PENDING", pending)
+
+ let paid = (!amount && received) || (amount > 0 && (pending >= amount || received >= amount));
if (paid && !url.pathname.endsWith('paid'))
throw redirect(307, `/${params.username}/invoice/${hash}/paid`);
diff --git a/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte b/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte
index 4d7aae51..c9619cee 100644
--- a/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte
+++ b/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte
@@ -21,7 +21,7 @@
{#if received}
<h1 class="text-3xl md:text-4xl font-bold mb-6">{$t('invoice.paymentSuccessful')}</h1>
<h2 class="text-2xl md:text-3xl font-semibold">
- {f(fiat(received, rate), currency)}
+ {f(fiat(received - tip, rate), currency)}
{#if tip}
<span class="text-lg">
+ {f(fiat(tip, rate), currency)}
@@ -29,7 +29,7 @@
{/if}
</h2>
<h3 class="text-secondary md:text-lg mb-6 mt-1">
- ⚡️{s(received)}
+ ⚡️{s(received - tip)}
{#if tip}
<span class="text-lg">
@@ -42,13 +42,13 @@
{#if pending}
<h1 class="text-3xl md:text-4xl font-bold mb-6">Payment detected</h1>
<h2 class="text-2xl md:text-3xl font-semibold">
- {f(fiat(pending, rate), currency)}
+ {f(fiat(pending - tip, rate), currency)}
{#if tip}
+ {f(fiat(tip, rate), currency)}
{/if}
</h2>
<h3 class="text-secondary md:text-lg mb-6 mt-1">
- ⚡️{s(pending)}
+ ⚡️{s(pending - tip)}
{#if tip}
<span class="text-lg">
+ ⚡️{s(tip)}